package cn.changein.framework.config;

import cn.changein.framework.core.schedule.quartz.StartQuartzExample;
import cn.changein.framework.core.schedule.spring.SpringTasks;
import org.quartz.Scheduler;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

/**
 * 定时任务自动配置(需要定时任务的可以放开注释)
 * 

 * @date: 2020-02-20
 * @copyright: 广州澄境科技有限公司
 */
//@Configuration
//@EnableScheduling
public class SchedulingConfig {

    /**
     * 定时任务执行测试,注意在Application上加@EnableScheduling
     *
     */
    @Bean
    public SpringTasks scheduledTasks() {
        return new SpringTasks();
    }

    /**
     * quartz方式，配置Scheduler实例
     *
     */
    @Bean
    public Scheduler scheduler(SchedulerFactoryBean schedulerFactoryBean) {
        return schedulerFactoryBean.getScheduler();
    }

    /**
     * 启动quartz的示例
     *
     */
    @Bean
    public StartQuartzExample startQuartzExample() {
        return new StartQuartzExample();
    }

}

